#version 300 es
uniform mat4 uMVPMatrix;
uniform mediump float bj;
uniform vec3 cameraPosition;
uniform mat4 uMMatrix;
uniform float maxLifeSpan;//

in vec4 aPosition;
out float sjFactor;
out vec4 vPosition;  

void main()     
{
   vec4 currPosition=uMMatrix * vec4(aPosition.xy,0.0,1);
   float d=distance(currPosition.xyz,cameraPosition);
   float s=1.0/sqrt(0.01+0.05*d+0.001*d*d);
   
   gl_PointSize=bj*s;
                     		
   gl_Position = uMVPMatrix * vec4(aPosition.xy,0.0,1);
   vPosition=vec4(aPosition.xy,0.0,aPosition.w);
   sjFactor=(maxLifeSpan-aPosition.w)/maxLifeSpan;
}                      